﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AAA.Recognition
{
    public class DigitalSample
    {
        private Sensor[] _sensors;
        private int _iHSensorCnt;
        private int _iVSensorCnt;
        private int _iValue;

        public DigitalSample(int iHSensorCnt, int iVSensorCnt)
        {
            _sensors = new Sensor[iHSensorCnt * iVSensorCnt];

            _iHSensorCnt = iHSensorCnt;
            _iVSensorCnt = iVSensorCnt;
        }


        public void SetSensor(int iX, int iY, Sensor sensor)
        {
            _sensors[iX + iY * _iHSensorCnt] = sensor;
        }

        public Sensor GetSensor(int iX, int iY)
        {
            return _sensors[iX + iY * _iHSensorCnt];
        }

        public Sensor[] Sensors
        {
            get { return _sensors; }
        }

        public int Value
        {
            get { return _iValue; }
            set { _iValue = value; }
        }

        public int MatchCount(Sensor[] sensors)
        {
            int iMatchCount = 0;

            for (int i = 0; i < sensors.Length; i++)
                if (_sensors[i].IsMatch(sensors[i]))
                    iMatchCount++;

            return iMatchCount;
        }
    }
}
